home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: Rich Paul <linguist@cyberspy.com>
- Newsgroups: comp.std.c++
- Subject: Re: Is RTTI required if polymorphic constructor exists
- Date: 17 Apr 1996 13:23:24 PDT
- Organization: Technical Resource Connection
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <31755193.113D@cyberspy.com>
- References: <4kng7f$kt9@nuscc.nus.sg> <4kr21b$6ar@mulga.cs.mu.OZ.AU> <4l30l2$31v@nuscc.nus.sg>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: Wed, 17 Apr 1996 16:16:19 -0400
- X-Mailer: Mozilla 2.01Gold (WinNT; I)
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMXVTPky4NqrwXLNJAQGOhwH/XG5Fzh8iGURUOkzafixAbf9biyypwKWb
- vfGBGyK3HontNlMbpLN1MnhNlnv6X54L98Yz5Bho4MjB4ToxCQFTRw==
- =kHXL
- Originator: austern@isolde.mti.sgi.com
-
- Satrajit Sujit Ghosh wrote:
- >
- > Would it be possible to illustrate efficient, convenient and
- > pratical use of the RTTI functions?
- >
-
- Hmmm ... well, this comes in handy:
-
- ostream &operator << ( ostream &os, const exception &e )
- {
- return os << endl
- << "Exception: " << typeid(e).name() << endl
- << "Message: " << e.what() << endl;
- };
-
- Since the typename of the exception carries some of the most relevent
- information about the exception, why not use it ... of course, the
- same thing could be done with virtual functions.
-
- The rule of thumb I've been told is not to use RTTI unless there's
- just no other way to do it.
-
-
- --
- #include <legalbs/standarddisclaimer>
- Rich Paul | If you like what I say, tell my
- C++, OOD, OOA, OOP, | employer, but if you don't,
- OOPs, I forgot one ... | don't blame them. ;->
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-